package Casino;

/***************************
Nathan Mulder
Troy Reed
Group Project
Casino
**************************/

import Casino.MainProgram;
import java.util.Scanner;

public class Wallet
{
	private static double money;
	private static double loanAmount;
		
	Scanner input = new Scanner(System.in);
	MainProgram main = new MainProgram();
	
	public void setMoney(double sm)
	{
		if ((money + sm) >= 0)
		{
			money = money + sm;
		}
		else
		{
			System.out.println("\n\n***Please Note: You are about out of cash. \n***You need to take out a loan to continue playing.\n***Any earnings or losses will not be recorded \n***Until you remedy the situation by taking out a loan.");
		}
	}
	public double getMoney()
	{
		return money;
	}
	public void setLoan(double sl)
	{
		if ((loanAmount + sl) >= 0)
		{
			loanAmount = loanAmount + sl;
		}
	}

	public void repayLoanAmount()
	{
		System.out.print("\nThe Loan Shark says:\nIt's about time! I was about to send Big Pete to find where my money was!\nHow much you got for me?: $");
		double repayment = input.nextDouble();
		
		if (repayment <= money)
		{
			if (repayment >= 0)
			{
				if ((loanAmount - repayment) >= 0)
				{
					setMoney((repayment * (-1)));
					setLoan((repayment * (-1)));
				}
				else
					System.out.println("What are you tryin' to pull? You don't owe me that much!\n\n***Note: If you are trying to donate money then \nI suggest that you donate to some charity to increase your luck.");
				}
			else
				System.out.println("No payin' negative cash. I don't do I.O.U.'s");
		}
		else
			System.out.println("\nYou tryin' to trick me? \nAn I.O.U. doesn't count as repayment bud!\nYou can't pay until you got some cash!\n");
	}
	public double getLoanAmount()
	{
		return loanAmount;
	}
		
	public void makeLoan()
	{
		System.out.println("The Loan Shark says: You wanna borrow some dough, eh? \nI'll loan you a grand with only 20% interest upon repayment.\nWhat do ya say?\n1...Yes\n2...No\nYour Choice:");
		int loanAnswer = input.nextInt();
		switch (loanAnswer)
		{
			case 1:
				if (loanAmount <= 500)
				{
					setLoan(1200);
					setMoney(1000);
					System.out.printf("Here's a grand.\nYou now have $%.2f in your wallet", getMoney());
				}
				else
				{
					System.out.println("The Loan Shark says: You kiddin' me?\nI just loaned you some dough!\nYou betta' not come back here until\nyou repay me at least half of what you owe me or I'll send\nBig Pete to bust your scrawny kneecaps!");
				}
				break;
			case 2:
				System.out.println("You're decision. \nI'll be here when you're broke and beggin' for some cash");
				break;
			default:
				System.out.print("I ain't playin' any games.\nEither take the cash or scram!\n1...Yes\n2...No\nYour Choice:");
				loanAnswer = input.nextInt();
				break;
				
		}
	}
}